#include "SDL/SDL.h"

#include "Thread.h"

int g_integer;

class subThread : public Thread
{
public:
	void run()
	{
		while(m_run)
		{
			SDL_Delay(1000);

			printf("thread \"%s\" running\n", m_name);
			fflush(stdout);

			g_integer++;
		}
	}

	bool running() { return m_run; }

	void stop()
	{
		printf("stopping \"%s\"\n", m_name);
		m_run = false;
	}

protected:
	bool m_run;
};

int main()
{
	subThread thread;
	thread.setName("omg thread");
	thread.start();

	subThread thread2;
	thread2.setName("omg thread2");
	thread2.start();

	g_integer = 0;

	while(g_integer < 10)
	{
		SDL_Delay(845);

		printf("main thread\n");
		fflush(stdout);

		g_integer++;
	}

	thread.stop();
	thread2.stop();

	return 0;
}

